/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jili.ubert.dao.db;

import java.io.Serializable;
import com.baidu.bjf.remoting.protobuf.Codec;
import com.baidu.bjf.remoting.protobuf.ProtobufProxy;
import com.baidu.bjf.remoting.protobuf.annotation.Protobuf;
import com.jili.ubert.code.CodeTool;
import java.io.IOException;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author dragon
 */
@Entity
@Table(name = "obj_index")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ObjIndex.findAll", query = "SELECT o FROM ObjIndex o"),
    @NamedQuery(name = "ObjIndex.findByIndexID", query = "SELECT o FROM ObjIndex o WHERE o.indexID = :indexID"),
    @NamedQuery(name = "ObjIndex.findByIndexObj", query = "SELECT o FROM ObjIndex o WHERE o.indexObj = :indexObj"),
    @NamedQuery(name = "ObjIndex.findByListingDate", query = "SELECT o FROM ObjIndex o WHERE o.listingDate = :listingDate"),
    @NamedQuery(name = "ObjIndex.findByIndexName", query = "SELECT o FROM ObjIndex o WHERE o.indexName = :indexName"),
    @NamedQuery(name = "ObjIndex.findByRegionID", query = "SELECT o FROM ObjIndex o WHERE o.regionID = :regionID"),
    @NamedQuery(name = "ObjIndex.findByMarketCode", query = "SELECT o FROM ObjIndex o WHERE o.marketCode = :marketCode"),
    @NamedQuery(name = "ObjIndex.findByOwnUserID", query = "SELECT o FROM ObjIndex o WHERE o.ownUserID = :ownUserID"),
    @NamedQuery(name = "ObjIndex.findByAlterUserID", query = "SELECT o FROM ObjIndex o WHERE o.alterUserID = :alterUserID"),
    @NamedQuery(name = "ObjIndex.findByCreateTime", query = "SELECT o FROM ObjIndex o WHERE o.createTime = :createTime"),
    @NamedQuery(name = "ObjIndex.findByTimeStamp", query = "SELECT o FROM ObjIndex o WHERE o.timeStamp = :timeStamp")})
public class ObjIndex implements Serializable {
	public static byte[] EnCode(ObjIndex msg) throws IOException {
		Codec<ObjIndex> Lcode = ProtobufProxy.create(ObjIndex.class);
		return Lcode.encode(msg);
	}
	public static ObjIndex DeCode(byte[] data) throws IOException {
	Codec<ObjIndex> Lcode = ProtobufProxy.create(ObjIndex.class);
		return Lcode.decode(data);
	}

    private static final long serialVersionUID = 1L;
    @Id
    //@GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "IndexID")
    @Protobuf
	private Integer indexID;
    @Basic(optional = false)
    @Column(name = "IndexObj")
    @Protobuf
	private String indexObj;
    @Basic(optional = false)
    @Column(name = "ListingDate")
    @Temporal(TemporalType.DATE)
    private Date listingDate;
	@Protobuf
	private long listingDateL;
    @Basic(optional = false)
    @Column(name = "IndexName")
    private String indexName;
	@Protobuf
	private byte[] indexNameBit;
    @Column(name = "RegionID")
    @Protobuf
	private String regionID;
    @Basic(optional = false)
    @Column(name = "MarketCode")
    @Protobuf
	private String marketCode;
    @Column(name = "OwnUserID")
    @Protobuf
	private String ownUserID;
    @Column(name = "AlterUserID")
    @Protobuf
	private String alterUserID;
    @Column(name = "CreateTime")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createTime;
	//@Protobuf
//tprivate long createTimeL;
    @Column(name = "TimeStamp")
    @Temporal(TemporalType.TIMESTAMP)
    private Date timeStamp;
	//@Protobuf
	//private long timeStampL;

    public ObjIndex() {
    }

    public ObjIndex(Integer indexID) {
        this.indexID = indexID;
    }

    public ObjIndex(Integer indexID, String indexObj, Date listingDate, String indexName, String marketCode) {
        this.indexID = indexID;
        this.indexObj = indexObj;
        this.listingDate = listingDate;
		this.listingDateL = CodeTool.DateToLong(listingDate);
        this.indexName = indexName;
		this.indexNameBit = CodeTool.StringToBit(indexName);
        this.marketCode = marketCode;
    }

    public Integer getIndexID() {
        return indexID;
    }

    public void setIndexID(Integer indexID) {
        this.indexID = indexID;
    }

    public String getIndexObj() {
        return indexObj;
    }

    public void setIndexObj(String indexObj) {
        this.indexObj = indexObj;
    }

    public Date getListingDate() {
        return listingDate;
    }

    public void setListingDate(Date listingDate) {
        this.listingDate = listingDate;
        this.setListingDateL(CodeTool.DateToLong(listingDate));
    }

    public String getIndexName() {
        return indexName;
    }

    public void setIndexName(String indexName) {
        this.indexName = indexName;
		this.setIndexNameBit(CodeTool.StringToBit(indexName));
    }

    public String getRegionID() {
        return regionID;
    }

    public void setRegionID(String regionID) {
        this.regionID = regionID;
    }

    public String getMarketCode() {
        return marketCode;
    }

    public void setMarketCode(String marketCode) {
        this.marketCode = marketCode;
    }

    public String getOwnUserID() {
        return ownUserID;
    }

    public void setOwnUserID(String ownUserID) {
        this.ownUserID = ownUserID;
    }

    public String getAlterUserID() {
        return alterUserID;
    }

    public void setAlterUserID(String alterUserID) {
        this.alterUserID = alterUserID;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
		//this.createTimeL = CodeTool.DateToLong(createTime);
    }

    public Date getTimeStamp() {
        return timeStamp;
    }

    public void setTimeStamp(Date timeStamp) {
        this.timeStamp = timeStamp;
		//this.timeStampL = CodeTool.DateToLong(timeStamp);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (indexID != null ? indexID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ObjIndex)) {
            return false;
        }
        ObjIndex other = (ObjIndex) object;
        if ((this.indexID == null && other.indexID != null) || (this.indexID != null && !this.indexID.equals(other.indexID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.jili.ubert.dao.db.ObjIndex[ indexID=" + indexID + " ]";
    }

    public long getListingDateL() {
        return listingDateL;
    }

    public void setListingDateL(long listingDateL) {
        this.listingDateL = listingDateL;
		this.listingDate = CodeTool.LongToDate(listingDateL);
    }

    public byte[] getIndexNameBit() {
        return indexNameBit;
    }

    public void setIndexNameBit(byte[] indexNameBit) {
        this.indexNameBit = indexNameBit;
		this.indexName = CodeTool.BitToString(indexNameBit);
    }
    
}
